﻿using System;
using System.Linq;

namespace CSharpToJavascript {

	public static class JavascriptGenerator {

		public static String CreateOutput(Boolean includeNamespace) {
			return CreateOutput(OutputType.Simple, includeNamespace);
		}

		public static String CreateOutput() {
			return CreateOutput(OutputType.Simple, false);
		}

		public static String CreateOutput(OutputType type, Boolean includeNamespace) {
			Type[] types = ElementFinder.Get();

			return String.Join(" ", types.Select(t => Generate(t, type, includeNamespace)));
		}

		private static String Generate(Type type, OutputType output, Boolean includeNamespace) {
			if (type.IsEnum) {
				return String.Format("var {0} = {{{1}}};", type.Name, String.Join(", ", Enum.GetNames(type).Select(n => String.Format("{0}: \"{0}\"", n))));
			}
			//else if (type.IsClass) {
			//    // TODO:
			//}
			//else {
			//    // TODO:
			//}

			return String.Empty;
		}
	}
}